#include <gtk/gtk.h>

gint count = 0;
gchar buf[6];


void quit ()
{
    gtk_exit (0);
}


void increase(GtkWidget *widget, GtkLabel *label)
{
    count++;
    sprintf(buf, "%d", count);
    gtk_label_set_text(label, buf);
}

void decrease(GtkWidget *widget,  GtkLabel *label)
{
    count--;
    sprintf(buf, "%d", count);
    gtk_label_set_text(label, buf);
}


int main (int argc, char *argv[])
{
    GtkBuilder      *builder;
    GtkWidget       *window;

    GtkWidget *plus;
    GtkWidget *minus;
    GtkWidget *result;

    gtk_init (&argc, &argv);
 
    builder = gtk_builder_new ();
    gtk_builder_add_from_file (builder, "glade.glade", NULL);

    window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
    plus = GTK_WIDGET(gtk_builder_get_object(builder, "plus"));
    minus = GTK_WIDGET(gtk_builder_get_object(builder, "minus"));
    result = GTK_WIDGET(gtk_builder_get_object(builder, "label"));
    
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect(plus, "clicked", G_CALLBACK(increase), result);
    g_signal_connect(minus, "clicked", G_CALLBACK(decrease), result);

    gtk_signal_connect (GTK_OBJECT (window), "destroy",
                GTK_SIGNAL_FUNC (quit), NULL);
    
    g_object_unref (G_OBJECT (builder));
        
    gtk_widget_show_all(window);                
    gtk_main ();
 
    return 0;
}